﻿<!--
 Copyright (c) 2011 Nokia Corporation.
 -->

<UserControl x:Class="SudokuMaster.GameOver"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="340" d:DesignWidth="460" IsTabStop="True">
    
	<UserControl.Resources>
		<Style x:Key="ButtonStyle1" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid Background="Transparent">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Pressed">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="10" Margin="{StaticResource PhoneTouchTargetOverhang}">
								<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
							</Border>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>

    <!--LayoutRoot is the root grid where all the content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}"
          Opacity="0.9" Height="340">
        
        <!-- Round the edges of the element a bit -->
        <Grid.Clip>
            <RectangleGeometry RadiusX="20" RadiusY="20" Rect="0,0,460,340" />
        </Grid.Clip>
        
        <!-- 
        Couple of textblocks; title, time and placement on highscore list.
        Data binding not used for them since the values are assigned only once at control creation.
        So data is passed as parameter to the class constructor.
        -->
        
        <TextBlock Height="100" HorizontalAlignment="Center" Margin="12,12,12,0"
                   Name="textBlockHeading" Text="COMPLETED!"
                   VerticalAlignment="Top" Width="436" FontSize="72" />
        <TextBlock Height="40" HorizontalAlignment="Center" Margin="12,120,12,0"
                   Name="textBlockTime" Text="Your time was 00:00"
                   VerticalAlignment="Top" Width="436" FontSize="26"
                   TextAlignment="Center" />
        <TextBlock Height="40" HorizontalAlignment="Center" Margin="12,158,14,0"
                   Name="textBlockPlacement" Text="Your placement is 1"
                   VerticalAlignment="Top" Width="434" FontSize="26"
                   TextAlignment="Center" />

        <!-- And a textbox for the player's name -->
        <TextBox Height="72" HorizontalAlignment="Left" Margin="12,196,0,0"
                 Name="playerName" Text="Your name" VerticalAlignment="Top"
                 Width="436" KeyDown="PlayerName_KeyDown" />

        <Button Name="ConfirmButton" Content="Confirm" Height="74" Width="140" 
                VerticalAlignment="Bottom" HorizontalAlignment="Center" Click="Button_Click" Style="{StaticResource ButtonStyle1}">            
        </Button>

        <!-- Animations -->
        <Grid.Resources>
            <!-- Animation used to fade in the entire control when it is created -->
            <Storyboard x:Name="fadeInAnimation">
                <DoubleAnimation
                    Storyboard.TargetName="LayoutRoot" 
                    Storyboard.TargetProperty="Opacity"
                    From="0.0" To="0.8" Duration="0:0:1" 
                    />
            </Storyboard>
            <!-- Animation used to fade out the entire control when it is being closed -->
            <Storyboard x:Name="fadeOutAnimation">
                <DoubleAnimation
                    Storyboard.TargetName="LayoutRoot" 
                    Storyboard.TargetProperty="Opacity"
                    From="0.8" To="0.0" Duration="0:0:1"
                    Completed="FadeOutAnimation_Completed" />
            </Storyboard>
        </Grid.Resources>
    </Grid>
</UserControl>
